<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="functions.asp" -->
<%

dim sql
dim isRcp

sql = "SELECT SEQNUM, REGNUM, INVNUM, EMPCODE,VENDORID, PONUM,INVSTATUS, SERVICERCP,"
sql = sql & "MULTIVERIFY,REFORDER,USERCOORD,INVAMOUNT,INVCURRENCY, "
sql = sql & "CONVERT(CHAR(10),INVRECDATE,101) as INVRECDATE2,"
sql = sql & "1 AS FRATE, "
sql = sql & "CURRENCYSYMBOL, VERIFIEDBY, VERIFIEDSTATUS,DEPARTMENT, AUTHORISEDBY, LOCATION, APPROVEDBY,"
sql = sql & "APPROVED2BY,JOINAPPROVAL,INVRECDATE, INVDUEDATE, DATEVERIFIED,DATEAUTHORISED,DATEAPPROVED,"
sql = sql & "DATEAPPROVED2,REFERENCEDOC, (SELECT TOP 1  VENDOR.NAME FROM VENDOR WHERE VENDOR.VENDORID=EXIREG.VENDORID) AS VENDORNAME, "
sql = sql & "(SELECT VERNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.VERIFIEDBY) AS VERNAME,"
sql = sql & "(SELECT AUTHNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.AUTHORISEDBY) AS AUTHNAME,"
sql = sql & "(SELECT APPRNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVEDBY) AS APPRNAME,"
sql = sql & "(SELECT APPRNAME2=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.APPROVED2BY) AS APPRNAME2,"
sql = sql & "(SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END FROM dbo.EMP WHERE EMP.EMPCODE=EXIREG.LOCATION) AS LOCNAME,"
sql = sql & "USERDEPT,COMMENTS  FROM dbo.EXIREG  WHERE SEQNUM=" & request.querystring("seqnum") 
sql = sql & "  AND  (USERCOORD='" & empCode & "' OR LOCATION='" & empCode &"' OR LOCATION='" & mgrCode & "')"

set EXIREG = cn.execute(sql)

if EXIREG.eof then
response.redirect "my_InvoiceDet.asp?seqnum=" & request.querystring("seqnum")
end if


sql = "SELECT *,  (SELECT TRDESCR FROM EXITRTYPE WHERE EXIHIST.TRANSTYPE=EXITRTYPE.TRTYPE) AS TRDESCR, "
'sql = sql & "(SELECT EMP.FIRSTNAME + ' '  + EMP.LASTNAME FROM dbo.EMP WHERE EMP.EMPCODE=EXIHIST.LOCATION) AS LOCNAME "
sql = sql & "(SELECT LOCNAME=CASE WHEN LASTNAME IS NOT NULL THEN EMP.FIRSTNAME + ' '  + EMP.LASTNAME "
sql = sql & " WHEN LASTNAME IS NULL THEN EMP.FIRSTNAME END "
sql = sql & " FROM dbo.EMP WHERE EMP.EMPCODE=EXIHIST.LOCATION) AS LOCNAME "
sql = sql & " FROM dbo.EXIHIST  WHERE SEQNUM=" & Request.Querystring("seqnum")

set InvHist = cn.execute(sql)

sql = "SELECT *  FROM dbo.COMPCODE"
set CompCode = cn.execute(sql)


sql = "SELECT *  FROM dbo.EXICHARGE  WHERE INVSEQNUM=" & Request.querystring("seqnum")
set Acct = cn.execute(sql)

sql = "SELECT *  FROM dbo.EXIVERIFY  WHERE INVSEQNUM=" & Request.QueryString("seqnum")
set Verification = cn.execute(sql)

Dim PONUM
PONUM=EXIREG("PONUM")

sql = "SELECT * FROM EXILINKRCP WHERE SEQNUM=" & Request.QueryString("seqnum")
set RcpLink = cn.execute(sql)

if RcpLink.eof then
  sql = "SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, "
  sql = sql & "UNITCOST, LINECOST, UDF  FROM dbo.PORECEIV  "
  sql = sql & "WHERE PONUM = '" & PONUM  & "'  AND INVOICENUM IS NULL"
else
  sql = "SELECT RECEIVERNUM, INVOICENUM, INVOICEDATE,INVOICESTATUS, PONUM, QTYRECEIVED, DATERECEIVED, "
  sql = sql & "UNITCOST, LINECOST, UDF  FROM dbo.PORECEIV  "
  sql = sql & "WHERE PONUM = '" & PONUM  & "'  AND INVOICENUM='" & EXIREG("INVNUM") & "'"
end if

set Receipt = cn.execute(sql)
if Receipt.eof then
isRcp="N"
else
isRcp="Y"
end if
%>
<%
dim isUser
dim isAuthorised
dim isOutLimit
dim btnCaption
dim btnCaption2
dim btnCaption3
dim TrType
dim Caption1
dim Caption2
dim Verseqnum
dim btnVisible
dim rsdoa, doacode

verseqnum=0
btnCaption2="Reject Invoice"

if (EXIREG("USERCOORD") <> "") then
btnVisible=isUC
VERUC=EXIREG("USERCOORD")
else
btnVisible="Y"
VERUC=EXIREG("VERIFIEDBY")
end if

Function get_Authorise(e)
'if (EXIREG.Fields.Item("APPROVEDBY").Value <> "") then
 sql = "SELECT  A.GROUPDESC, A.EMPCODE, B.CURRENCY, B.INVAMTPO, B.INVAMTNONPO"
 sql = sql & " FROM dbo.EXIAUTHORITY A, dbo.EXIAUTHFINANCE B"
 sql = sql & " WHERE A.GROUPDESC=B.GROUPDESC "
 sql = sql & " AND (A.EMPCODE = '" & e & "' OR A.DOATO= '" & e & "')"

 set rs = cn.execute(sql)
 
do while not rs.eof
 if (EXIREG("REFORDER")= "Y")or(EXIREG("REFORDER")= "O") then
   if ((EXIREG("INVAMOUNT")/EXIREG("FRATE")) > rs("INVAMTPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 else
   if ((EXIREG("INVAMOUNT")/EXIREG("FRATE")) > rs("INVAMTNONPO")) then
     get_Authorise = "N"
   else
     get_Authorise = "Y"
   end if
 end if
 
rs.movenext
loop
set rs = nothing
'end if

end function

TrType = "unknown"

if (isUC="Y") then
 btnCaption = " Route Invoice "
 TrType = "Route"
 if (EXIREG("INVSTATUS") ="REJECTED") then
 btnCaption2 = "Route Back to Finance"
 btnCaption3 = btnCaption3 & ""
 end if
end if

if (empCode = EXIREG("VERIFIEDBY")) then
 btnCaption = " Verify Invoice "
 TrType = "Verify"
end if

if (EXIREG("APPROVEDBY")<>"")then
isAuthorised=get_Authorise(EXIREG("APPROVEDBY"))
end if
if (EXIREG("APPROVEDBY")=empCode) or (EXIREG("APPROVEDBY")=mgrCode)then
 if (isAuthorised = "Y") then   
   btnCaption = " Approve Invoice "
   TrType = "Approve"
 else
   TrType = "PreApprove"
   btnCaption = " Approve Invoice "
 end if
end if

if (EXIREG("APPROVED2BY")<>"")then
	isAuthorised=get_Authorise(EXIREG("APPROVED2BY"))
end if

'Added 09 Oct 2006 to handle DOA for APPROVED2BY
'In the future, this should applied also for any above conditions
set rsdoa = cn.execute("SELECT DOATO FROM dbo.EXIAUTHORITY WHERE EMPCODE='" & EXIREG("APPROVED2BY") & "'")
if rsdoa.eof then doacode="" else doacode = rsdoa("doato") end if
if (EXIREG("APPROVED2BY")=empCode) or (EXIREG("APPROVED2BY")=mgrCode) or (empcode=doacode) then
 if (isAuthorised = "Y") then  
   btnCaption = " Approve Invoice "
   TrType = "Approve2"
 else
   TrType = "PreApprove2"
   btnCaption = " Approve Invoice "
 end if
end if

'Added 09 Oct 2006 to handle DOA for AUTHORISEDBY
'In the future, this should applied also for any above conditions
set rsdoa = cn.execute("SELECT DOATO FROM dbo.EXIAUTHORITY WHERE EMPCODE='" & EXIREG("AUTHORISEDBY") & "'")
if rsdoa.eof then doacode="" else doacode = rsdoa("doato") end if
'if (empCode = EXIREG("AUTHORISEDBY")) then
if (empCode = EXIREG("AUTHORISEDBY")) or (empcode=doacode) then
   btnCaption = " Approve Invoice "
   TrType = "Approve"
   'isAuthorised = "N"
end if

set rsdoa = nothing

if (EXIREG("MULTIVERIFY")="Y" ) then
  sql = "SELECT *  FROM EXIVERIFY WHERE INVSEQNUM=" & request.querystring("seqnum")
  sql = sql & " AND VERIFIEDBY='" & empCode & "'"
  sql = sql & " AND VERIFYSTATUS='NOT VERIFY'"
  set rs = cn.execute(sql)
  Do while not rs.eof 
    btnCaption = " Verify Invoice "
    TrType = "MultiVerify"
	VerSeqnum = rs("SEQNUM")
  rs.movenext
  loop
end if

if(EXIREG("JOINAPPROVAL")="Y") then
  caption1="Approved 1 By:"
  caption2="Approved 2 By:"
else
  caption1="Approved By:"
end if

%>
<SCRIPT Language = "JavaScript">
String.prototype.reverse = function () {return this.split('').reverse().join('')}; 
Number.prototype.withCommas = function () { 
if (isNaN (this)) return NaN.toString(); 
var l = Math.floor(Math.abs(this)).toString(); 
var r = Math.round((Math.abs(this) % 1) * 100).toString(); 
return [(this < 0 ? '-' : ''), (l.length > 3 ? l.reverse().match(/\d{1,3}/g).join(',').reverse() : l),'.', (r < 10 ? '0' + r : r)].join(''); 
} 

function Valid_Charge(dField, x, y){
var re=/\,/g;//untuk mereplace koma
var ldField=dField.length;
var dtTotal=y;
var initval=Number(x.value.replace(re,""));
var t=document.getElementsByTagName("input");
var total=0;
if (initval!=0)
for (var j=0; j<t.length; j++){
if (t[j].name.substring(0,ldField)==dField)
total= total + Number(t[j].value.replace(re,""));
}
 if (total > dtTotal ){
     alert("Total amount is greater than invoice amount!");
     x.focus();
	 x.value=0;
     return false;
	 }
	 else {

x.value=initval.withCommas();
return true
}
//x.value=Number(x.value.replace(re,"")).withCommas();

}

function DocLoad(){
var multiver='<%=(EXIREG("MULTIVERIFY"))%>';
var joinAppr='<%=(EXIREG("JOINAPPROVAL"))%>';
var isUC='<%= isUC %>';
var isAuthorised='<%= isAuthorised %>';
document.getElementById("inv_hist").style.display='none';
if (joinAppr=='N'){
  document.getElementById("Approved2").style.display='none';
  }
if (isAuthorised=='N'){
  document.getElementById("Authorise").style.display='block';
  }
else
  {
  document.getElementById("Authorise").style.display='none';
  //document.form1.reqAuthorised.value=' ';
  }
}

function Reject_Inv(){
		window.location = "Reject_Inv.asp?RecBy=<%=(EXIREG("EMPCODE"))%>&UC=<%=(EXIREG("USERCOORD"))%>&isUC=<%= isUC %>&seqnum=<%=(EXIREG("SEQNUM"))%>&VendorName=<%=(EXIREG("VENDORNAME"))%>&InvoiceNo=<%=(EXIREG("INVNUM"))%>"
		} 

function NotifyUser(){
        var empCode='<%= empCode %>'; 
		var invStatus='<%=(EXIREG("INVSTATUS"))%>';
		var status=document.form1.status.value;
if ((status=="REJECTED")||(invStatus=='APPROVED')){
 alert("Cannot send notification, invoice already rejected or approved!");
 return false;
}
else
{
        if (empCode=='<%=(EXIREG("LOCATION"))%>'){
		alert('Cannot send notification to yourself!');
		return false;
		}
		else{
		window.location = "Send_notification.asp?isUC=Y&Loc=<%=(EXIREG("LOCATION"))%>&LocName=<%=(EXIREG("LOCNAME"))%>&seqnum=<%=(EXIREG("SEQNUM"))%>&VendorName=<%=(EXIREG("VENDORNAME"))%>&InvoiceNo=<%=(EXIREG("INVNUM"))%>" 
  }
}
}

function checkVerName()
{ if (document.form1.reqEndUser.value == '<%= empCode %>')
   { document.form1.btnRoute.value = ' Verify Invoice ';
     document.form1.TrType.value = 'Verify';
   }
   else
   { document.form1.btnRoute.value = ' Route Invoice ';
     document.form1.TrType.value = 'Route'; } 
}

function displayTbl(cb)
{var e=cb.value;
 var myRow1=document.getElementById("userVer");
 var myRow2=document.getElementById("usrTable");
 if (e=='Y') {
    if (myRow1.style.display=='none')
	   {
	   myRow1.style.display='block'; }
	else
	    {
	   myRow1.style.display='none'; }
	if( myRow2.style.display=='none')
	   {
	   myRow2.style.display='block';}
	else
	   {
	   myRow2.style.display='none';}
	}
 else
   {
    myRow1.style.display='none';
	myRow2.style.display='none';
	}
    //document.getElementById("userVer").getElementsByTagName("TBODY")[0].visible=false;
}

function ShowAppr(cb2)
{ var e2=cb2.value;
  var rowAppr=document.getElementById("Approved2");
  var txt1=document.getElementById("caption1");
  var txt2=document.getElementById("caption2");
  if (e2=='Y') {
    if (rowAppr.style.display=='none')
	   {rowAppr.style.display='block';
	   txt1.innerHTML='Approved 1 By: ';
	   txt1.style.fontWeight = "bold";
	   txt2.innerHTML='Approved 2 By: ';
	   txt2.style.fontWeight = "bold";}
	else 
	   { rowAppr.style.display='none';
	     txt1.innerHTML='Approved By: ';
		fontWeight = "bold";}
  }
  else
  {rowAppr.style.display='none';}
}

function show_hist(dfield){
//var txt=document.getElementById("caption3");
//if (dfield.checked) {
//document.getElementById("inv_hist").style.display='block';
//txt.innerHTML='Hide History';
//} 
//else {
//document.getElementById("inv_hist").style.display='none';
//txt.innerHTML='View History';}
if (document.getElementById("inv_hist").style.display=='none'){
document.getElementById("inv_hist").style.display='block';
dfield.value=' Hide History ';
} 
else {
document.getElementById("inv_hist").style.display='none';
dfield.value=' View History ';}
}

function Valid_DOA(x,y)
{
  var Amt_PO=x;
  var Amt_nonPO=y;
  var Ex_rate= <%=EXIREG("FRATE") %>;
  var Inv_Amt= <%= EXIREG("INVAMOUNT") %>;
  var Ref='<%= EXIREG("REFORDER") %>';
  if (Ref=='Y') {
    if ((Inv_Amt/Ex_rate)>Amt_PO){
	  document.getElementById("Authorise").style.display='block';
	  document.form1.reqAuthorised.value='';
    }
	else
	{
	  document.getElementById("Authorise").style.display='none';
	  document.form1.reqAuthorised.value=' ';
    }
  }
  else
  {
    if ((Inv_Amt/Ex_rate)>Amt_nonPO){
	  document.getElementById("Authorise").style.display='block';
	  document.form1.reqAuthorised.value='';
    }
	else
	{
	  document.getElementById("Authorise").style.display='none';
	  document.form1.reqAuthorised.value=' ';
    }
  }
  
}

function formSubmit(which) { 
var pass=true;
var status=document.form1.status.value;
var isUC='<%= isUC %>';
if ((status=="REJECTED")&&(isUC=="N")){
 alert("Cannot edit REJECTED invoice!");
 return false;
}
else
{
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,3)=="req") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
         }
      }
   }
}
if (!pass) {
shortFieldName=tempobj.name.substring(3,30).toUpperCase();
alert("Please make sure the " + shortFieldName + " field was properly completed.");
return false;
}
else
  {
  
  if ((document.form1.hf.value == "a")||(document.form1.hf.value == "b")){ 
  document.form1.action= "My_InvProcess_mgr.asp"; 
  } 
  if (document.form1.hf.value == "c") {
     if (document.form1.Comments.value!=""){ 
     document.form1.action= "Reject_Inv.asp";}
     else{
     alert("Please type your comments.");
     return false;} 
	 }
  if (document.form1.hf.value == "d")   { 
  document.form1.action= "Update_receipt.asp"; 
  } 
  return true;
  }
}
} 

function validate_charge(a,b,c,src)
{var y=b.value;
 if (y!="") {
window.open("ValCharge.asp?T0="+a+"&T1="+y+"&T2="+c+"&src="+src,"","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else src.value="";
}
function validate_charge2(a,b,c,src)
{var y=c.value;
 if (y!="") {
window.open("ValCharge.asp?T0="+a+"&T1="+b+"&T2="+y+"&src="+src,"","width=300,height=120,Top=240,Left=240,toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no,resizable=no,")
} 
else src.value="";
}

function setAmt(){
if ((document.form1.ActCode1.value!="")&&(document.form1.Amt1.value=="0"))
document.form1.Amt1.value=<%=(EXIREG("INVAMOUNT"))%>;
}

function addRow(id){			
var rows = Number(document.form1.Incr.value);			
var tbody = document.getElementById(id).getElementsByTagName("TBODY")[0];
var row = document.createElement("TR");
row.setAttribute("bgColor","#ffffff");
            
//create input box
var hf1 = document.createElement("INPUT");
hf1.setAttribute("type","hidden");
hf1.setAttribute("name","seqnum" + rows);
hf1.setAttribute("value","0");


var ip1 = document.createElement("INPUT");
ip1.setAttribute("TYPE","TEXT");
ip1.setAttribute("name","ActCode" + rows);
ip1.setAttribute("id","ActCode" + rows);
ip1.setAttribute("size","40");
ip1.setAttribute("className","GridBox");
ip1.onblur=function(){setAmt()};

var bt1=document.createElement("INPUT");
bt1.setAttribute("type","button");
bt1.setAttribute("value","...");
bt1.setAttribute("name","Butt1" + rows);
bt1.setAttribute("className","sbttn");

bt1.onclick=function(){OpenAccountCodeList('','ActCode' +rows)};

var ip2 = document.createElement("INPUT");
ip2.setAttribute("TYPE","TEXT");
ip2.setAttribute("name","Amt" + rows);
ip2.setAttribute("size","20");
ip2.setAttribute("value","0.00");
ip2.setAttribute("className","GridNumBox");
ip2.onblur=function(){Valid_Charge('Amt',this,<%= EXIREG("INVAMOUNT") %>)};

var ip3 = document.createElement("INPUT");
ip3.setAttribute("TYPE","TEXT");
ip3.setAttribute("name","Desc" + rows);
ip3.setAttribute("id","Desc" + rows);
ip3.setAttribute("size","40");
			
//create column
var td1 = document.createElement("TD");
td1.setAttribute("align","right");
td1.appendChild(document.createTextNode(rows+". "));

var td2 = document.createElement("TD");
td2.setAttribute("align","center");
td2.appendChild(document.getElementById("form1").appendChild(hf1));
td2.appendChild(document.getElementById("form1").appendChild(ip1));
td2.appendChild(document.getElementById("form1").appendChild(bt1));

var td3 = document.createElement("TD");
td3.setAttribute("align","center");
td3.appendChild(document.getElementById("form1").appendChild(ip2));

var td4 = document.createElement("TD");
td4.setAttribute("align","center");
td4.appendChild(document.getElementById("form1").appendChild(ip3));

            
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);

tbody.appendChild(row);
document.form1.Incr.value = rows + 1;
}



</SCRIPT>
<!-- #include file="pagetop_usr.asp" -->

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr> 
    <td nowrap height="21" bgcolor="#FFFFFF" width="3%" background="images/menu_end.gif">&nbsp;</td>
    <td nowrap height="21" bgcolor="#FFFFFF" width="28"> 
      <div align="center"><img src="images/menu_awal_off.gif" width="28" height="33"></div>
    </td>
    <td width="15%" background="images/menuoff.gif" height="21" nowrap> 
      <div align="center"><b><a href="My_invoice.asp" class="menu">My Invoice</a></b></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_off_separator.gif" width="28" height="33"></td>
    <td nowrap height="21" width="15%" background="images/menuoff.gif"> 
      <div align="center"><a href="My_invoice_List.asp?InvStatus=0&RefOrder=0&CurSymbol=N" class="menu">My 
        Invoice Archive </a></div>
    </td>
    <td nowrap height="21" width="28"><img src="images/menu_off_on_separator.gif" width="28" height="33"></td>
    <td width="15%" background="images/menuon.gif" height="21" nowrap> 
      <div align="center"><b class="menu">Invoice Approval</b></div>
    </td>
    <td height="21" bgcolor="#FFFFFF" width="11"><img src="images/Menu_onend.gif" width="13" height="33"></td>
    <td height="21" bgcolor="#FFFFFF" background="images/menu_end.gif"> 
      <div align="right"></div>
    </td>
  </tr>
  <tr bgcolor="#93bee2"> 
    <td height="21" width="3%" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="15%" height="21" bgcolor="#93bee2">&nbsp;</td>
    <td height="21" width="28">&nbsp;</td>
    <td height="21" width="15%">&nbsp;</td>
    <td height="21" width="28" bgcolor="#93bee2">&nbsp;</td>
    <td width="15%" height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
    <td height="21">&nbsp;</td>
  </tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#93bee2">
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF"><img src="images/curv_data.gif" width="21" height="21"></td>
    <td bgcolor="#FFFFFF" width="94%"></td>
  </tr>
  <tr> 
    <td width="4%">&nbsp;</td>
    <td width="2%" bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF" width="94%"> 
      <form name="form1" method="post" action="" onSubmit="return formSubmit(this);">
        <table width="100%" border="0" cellspacing="2" cellpadding="3">
          <tbody> 
          <tr> 
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b>Invoice No.:&nbsp;</b></div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td width="30%" height="21"> <%=(EXIREG("INVNUM"))%> 
              <input type="hidden" name="seqnum" value="<%=(EXIREG("SEQNUM"))%>">
            </td>
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b>Reference Order:&nbsp;</b></div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td height="21" width="18%"><%=(EXIREG("PONUM"))%> </td>
            <td height="21"><font color="#FF0000" size="1"> 
              <input type="button" name="Submit5" value=" View Original Invoice " class="sbttn" onClick="opennew('<%=(EXIREG("REFERENCEDOC"))%>')">
              </font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b>Vendor:&nbsp;</b></div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td width="30%" height="21"><%=(EXIREG("VENDORID"))%>&nbsp;&nbsp;&nbsp;<%=(EXIREG("VENDORNAME"))%></td>
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b><font color="#FF0000" size="1"> 
                <input type="hidden" name="TrType" value="<%= TrType %>">
                <input type="hidden" name="status" value="<%=(EXIREG("INVSTATUS"))%>">
                <input type="hidden" name="Authorised" value="<%= isAuthorised %>">
                <input type="hidden" name="isUC" value="<%= isUC %>">
                <input type="hidden" name="UC" value="<%=(VERUC)%>">
                <input type="hidden" name="recBy" value="<%=(EXIREG("EMPCODE"))%>">
                <input type="hidden" name="PONum" value="<%=(EXIREG("PONUM"))%>">
<!--  Added July 20, 2007 by DANNY GUNAWAN -->
			  <input type="hidden" name="servicercp" value="<%=(EXIREG("servicercp"))%>">
<!--  End of additional codes -->				
                </font>Department:&nbsp;</b></div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td bgcolor="#FFFFFF" height="21" width="18%"><%=(EXIREG("USERDEPT"))%> 
            </td>
            <td bgcolor="#FFFFFF" height="21"><font color="#FF0000" size="1"> 
              <input type="button" name="Submit4" value=" View Audit Trail " class="sbttn" onClick="show_hist(this)">
              </font></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b>Invoice Amount:&nbsp;</b></div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td width="30%" height="21"><b><%=(EXIREG("CURRENCYSYMBOL"))%>&nbsp;&nbsp;<%= FormatNumber((EXIREG("INVAMOUNT")), -1, -2, -2, -1) %></b></td>
            <td width="15%" bgcolor="#efefef" height="21"> 
              <div align="right"><b> 
                <input type="hidden" name="joinAppr" value="<%=(EXIREG("JOINAPPROVAL"))%>">
                <input type="hidden" name="VendorName" value="<%=(EXIREG("VENDORNAME"))%>">
                <input type="hidden" name="InvoiceNo" value="<%=(EXIREG("INVNUM"))%>">
                <input type="hidden" name="Reforder" value="<%=(EXIREG("REFORDER"))%>">
                Due Date:</b>&nbsp;</div>
            </td>
            <td width="2%" height="21">&nbsp;</td>
            <td height="21" colspan="2"><%= DoDateTime((EXIREG("INVDUEDATE")), 1, 2057) %> 
              <input type="hidden" name="InvRecDate" value="<%= EXIREG("INVRECDATE2") %>">
            </td>
          </tr>
          <tr id="userVer" > 
            <td width="15%" valign="top"></td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"><b>Approval &amp; Verification: 
              <input type="hidden" name="VSeqnum" value="<%= verSeqnum %>">
              </b></td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#efefef" valign="middle"> 
              <div align="right"><b>Verified By:&nbsp;&nbsp; 1.&nbsp;&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="reqEndUser" size="10" value="<%=(EXIREG("VERIFIEDBY"))%>" readonly=true>
              <input type="text" name="empName" size="30" class="GridBox" value="<%=(EXIREG("VERNAME"))%>">
              &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("VERIFIEDSTATUS")="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              <%= EXIREG("DATEVERIFIED") %> 
              <% end if %>
              <input type="hidden" name="Dept" size="15" class="InputBox" value="<%=(EXIREG("USERDEPT"))%>">
            </td>
          </tr>
          <% Incr = 1  
				do while not Verification.EOF %>
          <tr id="userVer<%= incr %>" > 
            <td width="15%" valign="middle" bgcolor="#efefef"> 
              <div align="right"><b><%= incr + 1 %>.&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="Ver<%= Incr %>" size="10" class="InputBox" value="<%=(Verification("VERIFIEDBY"))%>">
              <input type="text" name="VerName<%= Incr %>" size="30" class="GridBox" value="<%=(Verification("VERNAME"))%>">
              &nbsp; 
              <% if (Verification("VERIFYSTATUS")="VERIFIED") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Verified 
              &nbsp;&nbsp;<%= DoDateTime((Verification("DATEVERIFIED")), 2, 2070) %> 
              <% end if %>
            </td>
          </tr>
          <% Incr = Incr + 1
                  Verification.MoveNext
                  loop %>
          <tr> 
            <td width="15%" bgcolor="#efefef" valign="middle"> 
              <div align="right" id="caption1"><b><%= caption1 %>&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="reqApproved" size="10" value="<%=(EXIREG("APPROVEDBY"))%>" readonly=true>
              <input type="text" name="ApprName" size="30" class="GridBox" value="<%=(EXIREG("APPRNAME"))%>">
              &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("DATEAPPROVED")<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              <%= EXIREG("DATEAPPROVED") %> 
              <% end if %>
              <input type="hidden" name="InvAmtNonPo">
              <input type="hidden" name="InvAmtPo">
            </td>
          </tr>
          <tr id="Approved2"> 
            <td width="15%" bgcolor="#efefef" valign="middle"> 
              <div align="right" id="caption2"><b><%= caption2 %>&nbsp;</b></div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="Approved2" size="10" value="<%=(EXIREG("APPROVED2BY"))%>" readonly=true>
              <input type="text" name="ApprName2" size="30" class="GridBox" value="<%=(EXIREG("APPRNAME2"))%>">
              &nbsp;&nbsp;&nbsp; 
              <% if (EXIREG("DATEAPPROVED2")<>"") then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Approved 
              <%= EXIREG("DATEAPPROVED2") %> 
              <% end if %>
              <input type="hidden" name="InvAmtNonPo2">
              <input type="hidden" name="InvAmtPo2">
            </td>
          </tr>
          <% 'if (isAuthorised = "N")  then %>
          <tr id="Authorise"> 
            <td width="15%" bgcolor="#efefef" valign="middle"> 
              <div align="right"><b>Authorised By:</b>&nbsp;</div>
            </td>
            <td width="2%" valign="middle">&nbsp;</td>
            <td colspan="5" valign="middle"> 
              <input type="hidden" name="reqAuthorised" size="10" value="<%=(EXIREG("AUTHORISEDBY"))%>" readonly=true>
              <input type="text" name="AuthoName" size="30" class="GridBox" value="<%= (EXIREG("AUTHNAME"))%>">
              &nbsp;&nbsp; 
              <% if (EXIREG("DATEAUTHORISED")<>"") and (EXIREG("AUTHORISEDBY")<>"")  then %>
              <img src="images/check.jpg" width="18" height="17">&nbsp;Authorised 
              <%= EXIREG("DATEAUTHORISED")%> 
              <% end if %>
              <input type="hidden" name="InvAmtPo3">
              <input type="hidden" name="InvAmtNonPo3">
            </td>
          </tr>
          <%' end if %>
          <tr> 
            <td width="15%" valign="top"> 
              <div align="right"></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="2"> <b>Comments:&nbsp;</b><br>
              <textarea name="Comments1" cols="45" rows="5" class="MemoBox" readonly="true"><%=(EXIREG("COMMENTS"))%></textarea>
            </td>
            <td width="2%"><br>
            </td>
            <td colspan="2"> <font color="#FF0000">Add your comments here:</font> 
              <textarea name="Comments" cols="45" rows="4" class="InputBox"></textarea>
            </td>
          </tr>
          <tr> 
            <td width="15%" bgcolor="#efefef" valign="top"> 
              <div align="right"><font color="#000000"><b>Allocation:</b></font></div>
            </td>
            <td width="2%"><font color="#003399"><b> </b></font></td>
            <td colspan="5"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999" id="Acct_tbl">
                <tr bgcolor="#D1DDEF"> 
                  <td width="5%" height="21"> 
                    <div align="center"><b>No</b></div>
                  </td>
                  <td width="30%"> 
                    <div align="center"><b>Account Code</b></div>
                  </td>                 
                  <td> 
                    <div align="center"><b>Amount (<%=(EXIREG("CURRENCYSYMBOL"))%>)</b></div>
                  </td>
				  <td width="30%"> 
                    <div align="center"><b>Description</b></div>
                  </td>
                </tr>
                <% dim Incr 
				Incr = 1 %>
                <% 
Do While NOT Acct.EOF
%>
                <tr> 
                  <td width="5%" bgcolor="#FFFFFF" align="right"> <%= Incr %>.</td>
                  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="hidden" name="seqnum<%= Incr %>" value="<%=(Acct("SEQNUM"))%>">
                      <input type="text" name="ActCode<%= Incr %>" class="GridBox" size="40" value="<%=(Acct("JDE_ACCOUNT_CODE"))%>" id="ActCode<%= Incr %>">
                      <input type="button" name="Butt1<%= Incr %>" value="..." class="sbttn" onClick="openpopup2('AcctList.asp?fld=AC<%= Incr %>')">
                    </div>
                  </td>
                  
                  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="text" name="Amt<%= Incr %>" size="20" class="GridNumBox" value="<%=FormatNumber( Acct("AMOUNT"), -1, -2, -2, -1)%>" onBlur="Valid_Charge('Amt',this,<%= EXIREG("INVAMOUNT") %>)">
                    </div>
                  </td>
				  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="text" name="Desc<%= Incr %>" class="GridBox" size="40" value="<%=(Acct("DESCRIPTION"))%>" id="Desc<%= Incr %>">
                    </div>
                  </td>
                </tr>
                <% Incr = Incr +1

  Acct.MoveNext
loop
%>
                <tr> 
                  <td width="5%" bgcolor="#FFFFFF" align="right"> <%= Incr %>.</td>
                  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="hidden" name="seqnum<%= Incr %>" value="0">
                      <input type="text" name="ActCode<%= Incr %>" class="GridBox" size="40" onBlur="setAmt()" id="AC<%= incr %>">
                      <input type="button" name="Butt1<%= Incr %>" value="..." class="sbttn" onClick="openpopup2('AcctList.asp?fld=AC<%= Incr %>')">
                    </div>
                  </td>
                  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="text" name="Amt<%= Incr %>" size="20" class="GridNumBox" value="0.00" onBlur="Valid_Charge('Amt',this,<%= EXIREG("INVAMOUNT") %>)">
                    </div>
                  </td>
				  <td bgcolor="#FFFFFF"> 
                    <div align="center"> 
                      <input type="text" name="Desc<%= Incr %>" class="GridBox" size="40" id="Desc<%= incr %>">
                    </div>
                  </td>
                </tr>
              </table>
              <table width="100%" border="0" cellspacing="1" cellpadding="2" bgcolor="#999999">
                <tr> 
                  <td bgcolor="#FFFFFF"> 
                    <input type="button" name="Submit8" value=" Add New Row " class="sbttn"  onClick="addRow('Acct_tbl')">
                    <% 'end if %>
                    <input type="hidden" name="Incr" value="<%= Incr+1 %>">
                  </td>
                </tr>
              </table>
              <br>
            </td>
          </tr>
          <tr id="inv_hist"> 
            <td width="15%" bgcolor="#FFFFFF">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="5"> 
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="6%" height="21"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="15%" height="21"> 
                    <div align="center"><b>Date</b></div>
                  </td>
                  <td height="21" bgcolor="#D1DDEF"> 
                    <div align="center"><b>Description</b></div>
                  </td>
                  <td width="13%" bgcolor="#D1DDEF" height="21"> 
                    <div align="center"><b>Department</b></div>
                  </td>
                  <td width="13%" height="21"> 
                    <div align="center"><b>Update By</b></div>
                  </td>
                </tr>
                <%  Incr = 1 %>
                <% 
Do While NOT InvHist.EOF
%>
                <tr bgcolor="#FFFFFF"> 
                  <td width="6%"> 
                    <div align="center"><%= Incr %>.</div>
                  </td>
                  <td width="15%"> 
                    <div align="center"><%= DoDateTime((InvHist("UPDATESTAMP")), 1, 2057) %></div>
                  </td>
                  <td><%=(InvHist("TRDESCR"))%>&nbsp;<%=(InvHist("LOCNAME"))%></td>
                  <td width="13%"><%=(InvHist("DEPARTMENT"))%></td>
                  <td width="13%"><%=(InvHist("UPDATEUSER"))%></td>
                </tr>
                <% 
  Incr = Incr + 1
  InvHist.MoveNext
Loop
%>
              </table>
            </td>
          </tr>
          <% if (EXIREG("INVSTATUS")="APPROVED") then %>
          <tr> 
            <td width="15%" bgcolor="#FFFFFF"> 
              <div align="right"></div>
            </td>
            <td width="2%"> 
              <input type="hidden" name="Incr3" value="<%= Incr %>">
            </td>
            <td colspan="5"> <b>Receipt:&nbsp;</b><br>
              <table width="100%" border="0" cellspacing="1" cellpadding="3" bgcolor="#999999">
                <tr bgcolor="#D1DDEF"> 
                  <td width="5%" height="21"> 
                    <div align="center"><b>No.</b></div>
                  </td>
                  <td width="6%" height="21"> 
                    <div align="center"><b>Select</b></div>
                  </td>
                  <td height="21"> 
                    <div align="center"><b>Remarks</b></div>
                  </td>
                  <td width="12%" height="21"> 
                    <div align="center"><b>Receiver No.</b></div>
                  </td>
                  <td width="12%" height="21"> 
                    <div align="center"><b>Date Recvd.</b></div>
                  </td>
                  <td width="10%" height="21"> 
                    <div align="center"><b>Qty </b></div>
                  </td>
                  <td width="15%" height="21"> 
                    <div align="center"><b> Cost</b></div>
                  </td>
                </tr>
                <% 
				   incr=1 %>
                <% 
Do While NOT Receipt.EOF
%>
                <tr bgcolor="#FFFFFF"> 
                  <td width="5%"> 
                    <div align="center"><%= incr %>.</div>
                  </td>
                  <td width="6%"> 
                    <div align="center"> 
                      <input type="checkbox" name="cb<%= incr %>" value="Y" <% if (Receipt("INVOICENUM")<>"") then response.write "checked" %>>
                    </div>
                  </td>
                  <td> 
                    <input type="hidden" name="rn<%= Incr %>" value="<%=(Receipt("RECEIVERNUM"))%>">
                    <%=(Receipt("UDF"))%></td>
                  <td width="12%"> 
                    <div align="center"><%=(Receipt("RECEIVERNUM"))%></div>
                  </td>
                  <td width="12%"> 
                    <div align="center"><%= DoDateTime((Receipt("DATERECEIVED")), 2, 2057) %></div>
                  </td>
                  <td width="10%"><%=(Receipt("QTYRECEIVED"))%></td>
                  <td width="15%"> 
                    <div align="right"> 
                      <% if (Receipt("UNITCOST")<>0) then %>
                      <%= FormatNumber((Receipt("UNITCOST")), -1, -2, -2, -1) %> 
                      <% end if %>
                      <% if (Receipt("LINECOST")<>0) then %>
                      <%= FormatNumber((Receipt("LINECOST")), -1, -2, -2, -1) %> 
                      <% end if %>
                    </div>
                  </td>
                </tr>
                <% incr=incr+1
  
  Receipt.MoveNext
loop
%>
              </table>
            </td>
          </tr>
          <tr> 
            <td width="15%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td colspan="5">&nbsp;</td>
          </tr>
          <% end if %>
          <% if (isUC="Y") then %>
          <tr> 
            <td width="15%" bgcolor="#efefef"> 
              <div align="right"><b>Action:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="5"> 
              <% if (EXIREG("INVSTATUS")="PARKED")or(EXIREG("INVSTATUS")="ROUTED")or(EXIREG("INVSTATUS")="PREAPPROVED")or(EXIREG("INVSTATUS")="REJECTED") then %>
              <input type="submit" name="Button4" value=" Save Changes " class="sbttn" onClick="document.form1.hf.value='b';">
              <% end if %>
              <% if (EXIREG("INVSTATUS")="APPROVED")and (EXIREG("SERVICERCP")="N")and (isRcp="Y")then %>
              <input type="submit" name="Submit6" value="Update Receipt" class="sbttn" onClick="document.form1.hf.value='d';">
              <% end if %>
              <input type="button" name="Button2" value=" Send Reminder " class="sbttn" onClick="NotifyUser()">
            </td>
          </tr>
          <% end if %>
          <tr> 
            <td width="15%" bgcolor="#efefef"> 
              <div align="right"><b>Action:&nbsp;</b></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td colspan="5"> 
              <% if (EXIREG("INVSTATUS")<>"REJECTED") then %>
              <input type="submit" name="btnRoute" value="<%= btnCaption %>" class="sbttn" onClick="document.form1.hf.value='a';">
              <% end if %>
              <input type="submit" name="Submit" value=" <%= btnCaption2  %> " class="sbttn" onClick="document.form1.hf.value='c';">
              <input type="hidden" name="hf" value="a">
              <div align="right"><b> </b></div>
            </td>
          </tr>
          </tbody> 
        </table>
      </form>
    </td>
  </tr>
</table>

</body>
</html>

<%
set InvHist=nothing
set CompCode=nothing
set Acct=nothing
set Verification=nothing
set Receipt=nothing
set EXIREG=nothing
'cn.Close
%>